#!/bin/bash
# 创建用户
# auto donghai


while [ true ]; do

read -r -p "请输入用户名：" ftp_name
read -r -p "请输入密码：" ftp_pwd
if [[ $ftp_name != null && $ftp_pwd != null && "$ftp_name" != "default" ]]; then
cat <<EOF >>/etc/vsftpd/vsftpd_user.txt 
$ftp_name
$ftp_pwd
EOF
break

elif [[ "$ftp_name" == "default" ]]; then
    echo "不能添加名称为default的用户"
else
    echo "用户名或密码输入错误"
fi
done

db_load -T -t hash -f /etc/vsftpd/vsftpd_user.txt /etc/vsftpd/vsftpd_login.db

cp "/etc/vsftpd/user_conf/default" "/etc/vsftpd/user_conf/$ftp_name"

systemctl restart vsftpd.service
